home *** CD-ROM | disk | FTP | other *** search
/ Gekikoh Dennoh Club 1 / Gekikoh Dennoh Club Vol. 1 (Japan).7z / Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin / kowin / archive / apl / beav13ko.lzh / humanio.c < prev    next >
C/C++ Source or Header  |  1995-11-15  |  3KB  |  173 lines

  1. /*
  2.  * The functions in this file negotiate with the operating system for
  3.  * characters, and write characters in a barely buffered fashion on the display.
  4.  * All operating systems.
  5.  */
  6.  
  7. #include    <sys_doslib.h>
  8. #include    "def.h"
  9.  
  10. int     nrow;                   /* Terminal size, rows.         */
  11. int     ncol;                   /* Terminal size, columns.      */
  12.  
  13. /*
  14.  * This function is called once to set up the terminal device streams.
  15.  * On VMS, it translates TT until it finds the terminal, then assigns
  16.  * a channel to it and sets it raw. On CPM it is a no-op.
  17.  */
  18.  
  19. void
  20. ttopen()
  21. {
  22. #ifdef KOWIN
  23.     nrow= ttrow= MTmScreenY;
  24. #else
  25.     int    y= B_CONSOL( -1, -1, -1, -1 );
  26.     nrow= ttrow= y & 0xffff;
  27. #endif
  28.     ncol= ttcol= 80;
  29. }
  30.  
  31. /*
  32.  * This function gets called just before we go back home to the command
  33.  * interpreter. On VMS it puts the terminal back in a reasonable state.
  34.  * Another no-operation on CPM.
  35.  */
  36. void
  37. ttclose()
  38. {
  39. }
  40.  
  41. /*
  42.  * Write a character to the display. On VMS, terminal output is buffered, and
  43.  * we just put the characters in the big array, after checking for overflow.
  44.  * On CPM terminal I/O unbuffered, so we just write the byte out. Ditto on
  45.  * MS-DOS (use the very very raw console output routine).
  46.  */
  47. void
  48. ttputc( c )
  49. {
  50. #ifdef KOWIN
  51.     MTmPutc( c );
  52. #else
  53.     B_PUTC( c );
  54. #endif
  55. }
  56.  
  57. /*
  58.  * Flush terminal buffer. Does real work where the terminal output is buffered
  59.  * up. A no-operation on systems where byte at a time terminal I/O is done.
  60.  */
  61. void
  62. ttflush()
  63. {
  64. #ifdef KOWIN
  65.     MTmFlush();
  66. #endif
  67. }
  68.  
  69. /*
  70.  * Read a character from the terminal, performing no editing and doing no echo
  71.  * at all. More complex in VMS that almost anyplace else, which figures. Very
  72.  * simple on CPM, because the system can do exactly what you want.
  73.  */
  74. ttgetc()
  75. {
  76. #ifdef KOWIN
  77.     static unsigned short    key_pad[]= {
  78.         0x23c,        /* 1 M-< 先頭*/
  79.         0x23e,        /* 2 M-> 最後*/
  80.         0x225,        /* 3 M-% 置換*/
  81.         0x253,        /* 4 M-s 検索*/
  82.         0x254,        /* 5 M-t 次*/
  83.         0x22e,        /* 6 M-. mark */
  84.         0x017,        /* 7 ^W  cut */
  85.         0x257,        /* 8 M-w copy */
  86.         0x019,        /* 9 ^Y yank */
  87.         0x43d,        /*10 ^X= show pos */
  88.         0x0,
  89.         0x0,
  90.         0x0,
  91.         0x0,
  92.         0x0,
  93.         0x0,
  94.         0x0,
  95.         0x0,
  96.         0x0,
  97.         0x0,
  98.  
  99.         0x016,        /* RUP     ^V    */
  100.         0x256,        /* RDW     M-V    */
  101.         0x449,        /* INS     ^XI    */
  102.         0x004,        /* DEL     ^D    */
  103.         0x010,        /* UP     ^P    */
  104.         0x002,        /* LEF     ^B    */
  105.         0x006,        /* RIG     ^F    */
  106.         0x00e,        /* DOW     ^N    */
  107.         0x00c,        /* CLR     ^L    */
  108.         0x23f,        /* HLP     M-?    */
  109.         0x558,        /* HOME ^X^X    */
  110.         0x0,        /* UNDO        */
  111.     };
  112.     unsigned int    c;
  113.     MTmSetAttr( MTaAttr, MTmFont_y );
  114.     if( (c= MTaGetc()) >= 0x100 )
  115.         c= key_pad[(c&0x1f)-1];
  116.     return    c;
  117. #else
  118.     unsigned int    c;
  119.     for(; !(c= INPOUT( 0xff )) ;)
  120.         CHANGE_PR();
  121.     return    c;
  122. #endif
  123. }
  124. ttkeyready()
  125. {
  126.     return    INPOUT( 0xfe );
  127. }
  128.  
  129. HumanGoto( x, y )
  130. {
  131. #ifdef KOWIN
  132.     MTmFlush();
  133.     MTmGoto( x, y );
  134. #else
  135.     B_LOCATE( x, y );
  136. #endif
  137. }
  138. HumanEol()
  139. {
  140. #ifdef KOWIN
  141.     MTmClrLine( 0 );
  142. #else
  143.     B_ERA_ED();
  144. #endif
  145. }
  146. HumanEop()
  147. {
  148. #ifdef KOWIN
  149.     MTmSetAttr( MTaAttr, MTmFont_y );
  150.     MTmClrScreen( 0 );
  151. #else
  152.     B_COLOR( 3 );
  153.     B_CLR_ED();
  154. #endif
  155. }
  156. HumanBeep()
  157. {
  158. }
  159. HumanColor( color )
  160. {
  161. #ifdef KOWIN
  162.     if( color )
  163.         MTmSetAttr( MTaAttr^AttrReverse, MTmFont_y );
  164.     else
  165.         MTmSetAttr( MTaAttr, MTmFont_y );
  166. #else
  167.     if( color )
  168.         B_COLOR( 11 );
  169.     else
  170.         B_COLOR( 3 );
  171. #endif
  172. }
  173.